	var imgObjPreview = $('#preview');
	var docObj = document.getElementById("doc");
	var $bg= document.getElementById("bg");
    function setImagePreview() {
        var Sys = {};
        var ua = navigator.userAgent.toLowerCase();
        var s;
        (s = ua.match(/msie ([\d.]+)/)) ? Sys.ie = s[1] :
        (s = ua.match(/firefox\/([\d.]+)/)) ? Sys.firefox = s[1] :
        (s = ua.match(/chrome\/([\d.]+)/)) ? Sys.chrome = s[1] :
        (s = ua.match(/opera.([\d.]+)/)) ? Sys.opera = s[1] :
        (s = ua.match(/version\/([\d.]+).*safari/)) ? Sys.safari = s[1] : 0;
        if (Sys.ie) {//Js判断为IE浏览器
            var imgSrc = "";
            if (Sys.ie == '9.0') {//Js判断为IE 9
                docObj.select();
                docObj.blur();
                imgSrc = document.selection.createRange().text;
                document.selection.empty();
            } else if (Sys.ie == '8.0' || Sys.ie == '7.0' || Sys.ie == '6.0') {//Js判断为IE 8 7 6
                $("#doc").select();
                imgSrc = document.selection.createRange().text;
                document.selection.empty();
            }
            //IE下，使用滤镜                       
            var localImagId = document.getElementById("localImag");
            //必须设置初始大小        
            localImagId.style.width = "134px";
            localImagId.style.height = "134px";
            //图片异常的捕捉，防止用户修改后缀来伪造图片
            try {
                localImagId.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale)";
                localImagId.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = imgSrc;
            } catch (e) {
                alert("您上传的图片格式不正确，请重新选择!");
                return false;
            }
            imgObjPreview.style.display = 'none';
            document.selection.empty();

        }
        if (Sys.firefox) {//Js判断为火狐(firefox)浏览器
            //火狐下，直接设img属性           
            imgObjPreview.css({"display":"block","width":"134px","height":"134px"});
            //imgObjPreview.attr("src",$("#doc").files[0].getAsDataURL();
            //火狐7以上版本不能用上面的getAsDataURL()方式获取，需要一下方式        
            imgObjPreview.attr("src",window.URL.createObjectURL(docObj.files[0]));
        }
        if (Sys.chrome) {//Js判断为谷歌chrome浏览器
            //alert(Sys.chrome);
			imgObjPreview.css({"display":"block","width":"134px","height":"134px"});
			imgObjPreview.attr("src",window.URL.createObjectURL(docObj.files[0]));
        }
        if (Sys.opera) {//Js判断为opera浏览器
            alert( Sys.opera);
        }
        if (Sys.safari) {//Js判断为苹果safari浏览器
            alert( Sys.safari);
        } 
        return true;
    }
    



//文件大小获取
//function filesize(ele) {  
//  var filesize = (ele.files[0].size / 1024).toFixed(2);  
//  if(filesize > 5120){  
//       alert("文件大于5M");  
//  }  
//   
//} 